import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import axios from 'axios'
import ElementPlus from 'element-plus'
import router from './router/index.js'
import 'element-plus/dist/index.css'
import VueVideoPlayer from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
import naive from 'naive-ui';
import store from './store';

import NProgress from 'nprogress'   // 导入 nprogress
import 'nprogress/nprogress.css'
import * as Icons from '@element-plus/icons-vue' // 引入所有图标，并命名为 Icons
import Recorder from 'recorder-core'
// 引入 echarts
import * as echarts from 'echarts'

// 引入DevUI及相关样式
import DevUI from 'vue-devui';
// import 'vue-devui/style.css';
import '@devui-design/icons/icomoon/devui-icon.css';


// 引入DevUI主题服务
// import { ThemeServiceInit, infinityTheme } from 'devui-theme';
// ThemeServiceInit({ infinityTheme }, 'infinityTheme');

//引入mp3格式支持文件；如果需要多个格式支持，把这些格式的编码引擎js文件放到后面统统引入进来即可
import 'recorder-core/src/engine/mp3'
import 'recorder-core/src/engine/mp3-engine'
import 'recorder-core/src/extensions/waveview'

//配置请求根路径
axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL
//axios拦截器拦截每一个请求,有token就配置头信息的token
axios.interceptors.request.use(config => {
    let token = window.localStorage.getItem('authorization')
    if (token) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
        config.headers.authorization = token
    }
    return config
}, error => {
    return Promise.reject(error)
})


const app = createApp(App)
for (let i in Icons) {
    app.component(i, Icons[i])
}
app.config.productionTip = false
app.use(ElementPlus)
app.use(router)
app.use(Recorder)
app.use(VueVideoPlayer)
// app.use(naive)
app.use(store)
// app.use(DevUI);
app.mount('#app')
// 全局挂载 echarts
app.config.globalProperties.$echarts = echarts
